<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/gtest/src/gtest-port.cc</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/gtest/src</a> - gtest-port.cc<span style="font-size: 80%;"> (source / <a href="gtest-port.cc.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">167</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">27</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2008, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Author: wan@google.com (Zhanyong Wan)
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : #include &quot;gtest/internal/gtest-port.h&quot;
<span class="lineNum">      33 </span>            : 
<span class="lineNum">      34 </span>            : #include &lt;limits.h&gt;
<span class="lineNum">      35 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      36 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">      37 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      40 </span>            : # include &lt;windows.h&gt;  // For TerminateProcess()
<span class="lineNum">      41 </span>            : #elif GTEST_OS_WINDOWS
<span class="lineNum">      42 </span>            : # include &lt;io.h&gt;
<span class="lineNum">      43 </span>            : # include &lt;sys/stat.h&gt;
<span class="lineNum">      44 </span>            : #else
<span class="lineNum">      45 </span>            : # include &lt;unistd.h&gt;
<span class="lineNum">      46 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            : #if GTEST_OS_MAC
<span class="lineNum">      49 </span>            : # include &lt;mach/mach_init.h&gt;
<span class="lineNum">      50 </span>            : # include &lt;mach/task.h&gt;
<span class="lineNum">      51 </span>            : # include &lt;mach/vm_map.h&gt;
<span class="lineNum">      52 </span>            : #endif  // GTEST_OS_MAC
<span class="lineNum">      53 </span>            : 
<span class="lineNum">      54 </span>            : #if GTEST_OS_QNX
<span class="lineNum">      55 </span>            : # include &lt;devctl.h&gt;
<span class="lineNum">      56 </span>            : # include &lt;sys/procfs.h&gt;
<span class="lineNum">      57 </span>            : #endif  // GTEST_OS_QNX
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : #include &quot;gtest/gtest-spi.h&quot;
<span class="lineNum">      60 </span>            : #include &quot;gtest/gtest-message.h&quot;
<span class="lineNum">      61 </span>            : #include &quot;gtest/internal/gtest-internal.h&quot;
<span class="lineNum">      62 </span>            : #include &quot;gtest/internal/gtest-string.h&quot;
<span class="lineNum">      63 </span>            : 
<span class="lineNum">      64 </span>            : // Indicates that this translation unit is part of Google Test's
<span class="lineNum">      65 </span>            : // implementation.  It must come before gtest-internal-inl.h is
<span class="lineNum">      66 </span>            : // included, or there will be a compiler error.  This trick is to
<span class="lineNum">      67 </span>            : // prevent a user from accidentally including gtest-internal-inl.h in
<span class="lineNum">      68 </span>            : // his code.
<span class="lineNum">      69 </span>            : #define GTEST_IMPLEMENTATION_ 1
<span class="lineNum">      70 </span>            : #include &quot;src/gtest-internal-inl.h&quot;
<span class="lineNum">      71 </span>            : #undef GTEST_IMPLEMENTATION_
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : namespace testing {
<span class="lineNum">      74 </span>            : namespace internal {
<span class="lineNum">      75 </span>            : 
<span class="lineNum">      76 </span>            : #if defined(_MSC_VER) || defined(__BORLANDC__)
<span class="lineNum">      77 </span>            : // MSVC and C++Builder do not provide a definition of STDERR_FILENO.
<span class="lineNum">      78 </span>            : const int kStdOutFileno = 1;
<span class="lineNum">      79 </span>            : const int kStdErrFileno = 2;
<span class="lineNum">      80 </span>            : #else
<span class="lineNum">      81 </span>            : const int kStdOutFileno = STDOUT_FILENO;
<span class="lineNum">      82 </span>            : const int kStdErrFileno = STDERR_FILENO;
<span class="lineNum">      83 </span>            : #endif  // _MSC_VER
<span class="lineNum">      84 </span>            : 
<span class="lineNum">      85 </span>            : #if GTEST_OS_MAC
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span>            : // Returns the number of threads running in the process, or 0 to indicate that
<span class="lineNum">      88 </span>            : // we cannot detect it.
<span class="lineNum">      89 </span>            : size_t GetThreadCount() {
<span class="lineNum">      90 </span>            :   const task_t task = mach_task_self();
<span class="lineNum">      91 </span>            :   mach_msg_type_number_t thread_count;
<span class="lineNum">      92 </span>            :   thread_act_array_t thread_list;
<span class="lineNum">      93 </span>            :   const kern_return_t status = task_threads(task, &amp;thread_list, &amp;thread_count);
<span class="lineNum">      94 </span>            :   if (status == KERN_SUCCESS) {
<span class="lineNum">      95 </span>            :     // task_threads allocates resources in thread_list and we need to free them
<span class="lineNum">      96 </span>            :     // to avoid leaks.
<span class="lineNum">      97 </span>            :     vm_deallocate(task,
<span class="lineNum">      98 </span>            :                   reinterpret_cast&lt;vm_address_t&gt;(thread_list),
<span class="lineNum">      99 </span>            :                   sizeof(thread_t) * thread_count);
<span class="lineNum">     100 </span>            :     return static_cast&lt;size_t&gt;(thread_count);
<span class="lineNum">     101 </span>            :   } else {
<span class="lineNum">     102 </span>            :     return 0;
<span class="lineNum">     103 </span>            :   }
<span class="lineNum">     104 </span>            : }
<span class="lineNum">     105 </span>            : 
<span class="lineNum">     106 </span>            : #elif GTEST_OS_QNX
<span class="lineNum">     107 </span>            : 
<span class="lineNum">     108 </span>            : // Returns the number of threads running in the process, or 0 to indicate that
<span class="lineNum">     109 </span>            : // we cannot detect it.
<span class="lineNum">     110 </span>            : size_t GetThreadCount() {
<span class="lineNum">     111 </span>            :   const int fd = open(&quot;/proc/self/as&quot;, O_RDONLY);
<span class="lineNum">     112 </span>            :   if (fd &lt; 0) {
<span class="lineNum">     113 </span>            :     return 0;
<span class="lineNum">     114 </span>            :   }
<span class="lineNum">     115 </span>            :   procfs_info process_info;
<span class="lineNum">     116 </span>            :   const int status =
<span class="lineNum">     117 </span>            :       devctl(fd, DCMD_PROC_INFO, &amp;process_info, sizeof(process_info), NULL);
<span class="lineNum">     118 </span>            :   close(fd);
<span class="lineNum">     119 </span>            :   if (status == EOK) {
<span class="lineNum">     120 </span>            :     return static_cast&lt;size_t&gt;(process_info.num_threads);
<span class="lineNum">     121 </span>            :   } else {
<span class="lineNum">     122 </span>            :     return 0;
<span class="lineNum">     123 </span>            :   }
<span class="lineNum">     124 </span>            : }
<span class="lineNum">     125 </span>            : 
<a name="126"><span class="lineNum">     126 </span>            : #else</a>
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span><span class="lineNoCov">          0 : size_t GetThreadCount() {</span>
<span class="lineNum">     129 </span>            :   // There's no portable way to detect the number of threads, so we just
<span class="lineNum">     130 </span>            :   // return 0 to indicate that we cannot detect it.
<span class="lineNum">     131 </span><span class="lineNoCov">          0 :   return 0;</span>
<span class="lineNum">     132 </span>            : }
<span class="lineNum">     133 </span>            : 
<span class="lineNum">     134 </span>            : #endif  // GTEST_OS_MAC
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span>            : #if GTEST_USES_POSIX_RE
<span class="lineNum">     137 </span>            : 
<a name="138"><span class="lineNum">     138 </span>            : // Implements RE.  Currently only needed for death tests.</a>
<span class="lineNum">     139 </span>            : 
<span class="lineNum">     140 </span><span class="lineNoCov">          0 : RE::~RE() {</span>
<span class="lineNum">     141 </span><span class="lineNoCov">          0 :   if (is_valid_) {</span>
<span class="lineNum">     142 </span>            :     // regfree'ing an invalid regex might crash because the content
<span class="lineNum">     143 </span>            :     // of the regex is undefined. Since the regex's are essentially
<span class="lineNum">     144 </span>            :     // the same, one cannot be valid (or invalid) without the other
<span class="lineNum">     145 </span>            :     // being so too.
<span class="lineNum">     146 </span><span class="lineNoCov">          0 :     regfree(&amp;partial_regex_);</span>
<span class="lineNum">     147 </span><span class="lineNoCov">          0 :     regfree(&amp;full_regex_);</span>
<span class="lineNum">     148 </span>            :   }
<span class="lineNum">     149 </span><span class="lineNoCov">          0 :   free(const_cast&lt;char*&gt;(pattern_));</span>
<span class="lineNum">     150 </span><span class="lineNoCov">          0 : }</span>
<a name="151"><span class="lineNum">     151 </span>            : </a>
<span class="lineNum">     152 </span>            : // Returns true iff regular expression re matches the entire str.
<span class="lineNum">     153 </span><span class="lineNoCov">          0 : bool RE::FullMatch(const char* str, const RE&amp; re) {</span>
<span class="lineNum">     154 </span><span class="lineNoCov">          0 :   if (!re.is_valid_) return false;</span>
<span class="lineNum">     155 </span>            : 
<span class="lineNum">     156 </span>            :   regmatch_t match;
<span class="lineNum">     157 </span><span class="lineNoCov">          0 :   return regexec(&amp;re.full_regex_, str, 1, &amp;match, 0) == 0;</span>
<span class="lineNum">     158 </span>            : }
<span class="lineNum">     159 </span>            : 
<a name="160"><span class="lineNum">     160 </span>            : // Returns true iff regular expression re matches a substring of str</a>
<span class="lineNum">     161 </span>            : // (including str itself).
<span class="lineNum">     162 </span><span class="lineNoCov">          0 : bool RE::PartialMatch(const char* str, const RE&amp; re) {</span>
<span class="lineNum">     163 </span><span class="lineNoCov">          0 :   if (!re.is_valid_) return false;</span>
<span class="lineNum">     164 </span>            : 
<span class="lineNum">     165 </span>            :   regmatch_t match;
<span class="lineNum">     166 </span><span class="lineNoCov">          0 :   return regexec(&amp;re.partial_regex_, str, 1, &amp;match, 0) == 0;</span>
<span class="lineNum">     167 </span>            : }
<a name="168"><span class="lineNum">     168 </span>            : </a>
<span class="lineNum">     169 </span>            : // Initializes an RE from its string representation.
<span class="lineNum">     170 </span><span class="lineNoCov">          0 : void RE::Init(const char* regex) {</span>
<span class="lineNum">     171 </span><span class="lineNoCov">          0 :   pattern_ = posix::StrDup(regex);</span>
<span class="lineNum">     172 </span>            : 
<span class="lineNum">     173 </span>            :   // Reserves enough bytes to hold the regular expression used for a
<span class="lineNum">     174 </span>            :   // full match.
<span class="lineNum">     175 </span><span class="lineNoCov">          0 :   const size_t full_regex_len = strlen(regex) + 10;</span>
<span class="lineNum">     176 </span><span class="lineNoCov">          0 :   char* const full_pattern = new char[full_regex_len];</span>
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span><span class="lineNoCov">          0 :   snprintf(full_pattern, full_regex_len, &quot;^(%s)$&quot;, regex);</span>
<span class="lineNum">     179 </span><span class="lineNoCov">          0 :   is_valid_ = regcomp(&amp;full_regex_, full_pattern, REG_EXTENDED) == 0;</span>
<span class="lineNum">     180 </span>            :   // We want to call regcomp(&amp;partial_regex_, ...) even if the
<span class="lineNum">     181 </span>            :   // previous expression returns false.  Otherwise partial_regex_ may
<span class="lineNum">     182 </span>            :   // not be properly initialized can may cause trouble when it's
<span class="lineNum">     183 </span>            :   // freed.
<span class="lineNum">     184 </span>            :   //
<span class="lineNum">     185 </span>            :   // Some implementation of POSIX regex (e.g. on at least some
<span class="lineNum">     186 </span>            :   // versions of Cygwin) doesn't accept the empty string as a valid
<span class="lineNum">     187 </span>            :   // regex.  We change it to an equivalent form &quot;()&quot; to be safe.
<span class="lineNum">     188 </span><span class="lineNoCov">          0 :   if (is_valid_) {</span>
<span class="lineNum">     189 </span><span class="lineNoCov">          0 :     const char* const partial_regex = (*regex == '\0') ? &quot;()&quot; : regex;</span>
<span class="lineNum">     190 </span><span class="lineNoCov">          0 :     is_valid_ = regcomp(&amp;partial_regex_, partial_regex, REG_EXTENDED) == 0;</span>
<span class="lineNum">     191 </span>            :   }
<span class="lineNum">     192 </span><span class="lineNoCov">          0 :   EXPECT_TRUE(is_valid_)</span>
<span class="lineNum">     193 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Regular expression \&quot;&quot; &lt;&lt; regex</span>
<span class="lineNum">     194 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;\&quot; is not a valid POSIX Extended regular expression.&quot;;</span>
<span class="lineNum">     195 </span>            : 
<span class="lineNum">     196 </span><span class="lineNoCov">          0 :   delete[] full_pattern;</span>
<span class="lineNum">     197 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     198 </span>            : 
<span class="lineNum">     199 </span>            : #elif GTEST_USES_SIMPLE_RE
<span class="lineNum">     200 </span>            : 
<span class="lineNum">     201 </span>            : // Returns true iff ch appears anywhere in str (excluding the
<span class="lineNum">     202 </span>            : // terminating '\0' character).
<span class="lineNum">     203 </span>            : bool IsInSet(char ch, const char* str) {
<span class="lineNum">     204 </span>            :   return ch != '\0' &amp;&amp; strchr(str, ch) != NULL;
<span class="lineNum">     205 </span>            : }
<span class="lineNum">     206 </span>            : 
<span class="lineNum">     207 </span>            : // Returns true iff ch belongs to the given classification.  Unlike
<span class="lineNum">     208 </span>            : // similar functions in &lt;ctype.h&gt;, these aren't affected by the
<span class="lineNum">     209 </span>            : // current locale.
<span class="lineNum">     210 </span>            : bool IsAsciiDigit(char ch) { return '0' &lt;= ch &amp;&amp; ch &lt;= '9'; }
<span class="lineNum">     211 </span>            : bool IsAsciiPunct(char ch) {
<span class="lineNum">     212 </span>            :   return IsInSet(ch, &quot;^-!\&quot;#$%&amp;'()*+,./:;&lt;=&gt;?@[\\]_`{|}~&quot;);
<span class="lineNum">     213 </span>            : }
<span class="lineNum">     214 </span>            : bool IsRepeat(char ch) { return IsInSet(ch, &quot;?*+&quot;); }
<span class="lineNum">     215 </span>            : bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, &quot; \f\n\r\t\v&quot;); }
<span class="lineNum">     216 </span>            : bool IsAsciiWordChar(char ch) {
<span class="lineNum">     217 </span>            :   return ('a' &lt;= ch &amp;&amp; ch &lt;= 'z') || ('A' &lt;= ch &amp;&amp; ch &lt;= 'Z') ||
<span class="lineNum">     218 </span>            :       ('0' &lt;= ch &amp;&amp; ch &lt;= '9') || ch == '_';
<span class="lineNum">     219 </span>            : }
<span class="lineNum">     220 </span>            : 
<span class="lineNum">     221 </span>            : // Returns true iff &quot;\\c&quot; is a supported escape sequence.
<span class="lineNum">     222 </span>            : bool IsValidEscape(char c) {
<span class="lineNum">     223 </span>            :   return (IsAsciiPunct(c) || IsInSet(c, &quot;dDfnrsStvwW&quot;));
<span class="lineNum">     224 </span>            : }
<span class="lineNum">     225 </span>            : 
<span class="lineNum">     226 </span>            : // Returns true iff the given atom (specified by escaped and pattern)
<span class="lineNum">     227 </span>            : // matches ch.  The result is undefined if the atom is invalid.
<span class="lineNum">     228 </span>            : bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
<span class="lineNum">     229 </span>            :   if (escaped) {  // &quot;\\p&quot; where p is pattern_char.
<span class="lineNum">     230 </span>            :     switch (pattern_char) {
<span class="lineNum">     231 </span>            :       case 'd': return IsAsciiDigit(ch);
<span class="lineNum">     232 </span>            :       case 'D': return !IsAsciiDigit(ch);
<span class="lineNum">     233 </span>            :       case 'f': return ch == '\f';
<span class="lineNum">     234 </span>            :       case 'n': return ch == '\n';
<span class="lineNum">     235 </span>            :       case 'r': return ch == '\r';
<span class="lineNum">     236 </span>            :       case 's': return IsAsciiWhiteSpace(ch);
<span class="lineNum">     237 </span>            :       case 'S': return !IsAsciiWhiteSpace(ch);
<span class="lineNum">     238 </span>            :       case 't': return ch == '\t';
<span class="lineNum">     239 </span>            :       case 'v': return ch == '\v';
<span class="lineNum">     240 </span>            :       case 'w': return IsAsciiWordChar(ch);
<span class="lineNum">     241 </span>            :       case 'W': return !IsAsciiWordChar(ch);
<span class="lineNum">     242 </span>            :     }
<span class="lineNum">     243 </span>            :     return IsAsciiPunct(pattern_char) &amp;&amp; pattern_char == ch;
<span class="lineNum">     244 </span>            :   }
<span class="lineNum">     245 </span>            : 
<span class="lineNum">     246 </span>            :   return (pattern_char == '.' &amp;&amp; ch != '\n') || pattern_char == ch;
<span class="lineNum">     247 </span>            : }
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            : // Helper function used by ValidateRegex() to format error messages.
<span class="lineNum">     250 </span>            : std::string FormatRegexSyntaxError(const char* regex, int index) {
<span class="lineNum">     251 </span>            :   return (Message() &lt;&lt; &quot;Syntax error at index &quot; &lt;&lt; index
<span class="lineNum">     252 </span>            :           &lt;&lt; &quot; in simple regular expression \&quot;&quot; &lt;&lt; regex &lt;&lt; &quot;\&quot;: &quot;).GetString();
<span class="lineNum">     253 </span>            : }
<span class="lineNum">     254 </span>            : 
<span class="lineNum">     255 </span>            : // Generates non-fatal failures and returns false if regex is invalid;
<span class="lineNum">     256 </span>            : // otherwise returns true.
<span class="lineNum">     257 </span>            : bool ValidateRegex(const char* regex) {
<span class="lineNum">     258 </span>            :   if (regex == NULL) {
<span class="lineNum">     259 </span>            :     // TODO(wan@google.com): fix the source file location in the
<span class="lineNum">     260 </span>            :     // assertion failures to match where the regex is used in user
<span class="lineNum">     261 </span>            :     // code.
<span class="lineNum">     262 </span>            :     ADD_FAILURE() &lt;&lt; &quot;NULL is not a valid simple regular expression.&quot;;
<span class="lineNum">     263 </span>            :     return false;
<span class="lineNum">     264 </span>            :   }
<span class="lineNum">     265 </span>            : 
<span class="lineNum">     266 </span>            :   bool is_valid = true;
<span class="lineNum">     267 </span>            : 
<span class="lineNum">     268 </span>            :   // True iff ?, *, or + can follow the previous atom.
<span class="lineNum">     269 </span>            :   bool prev_repeatable = false;
<span class="lineNum">     270 </span>            :   for (int i = 0; regex[i]; i++) {
<span class="lineNum">     271 </span>            :     if (regex[i] == '\\') {  // An escape sequence
<span class="lineNum">     272 </span>            :       i++;
<span class="lineNum">     273 </span>            :       if (regex[i] == '\0') {
<span class="lineNum">     274 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i - 1)
<span class="lineNum">     275 </span>            :                       &lt;&lt; &quot;'\\' cannot appear at the end.&quot;;
<span class="lineNum">     276 </span>            :         return false;
<span class="lineNum">     277 </span>            :       }
<span class="lineNum">     278 </span>            : 
<span class="lineNum">     279 </span>            :       if (!IsValidEscape(regex[i])) {
<span class="lineNum">     280 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i - 1)
<span class="lineNum">     281 </span>            :                       &lt;&lt; &quot;invalid escape sequence \&quot;\\&quot; &lt;&lt; regex[i] &lt;&lt; &quot;\&quot;.&quot;;
<span class="lineNum">     282 </span>            :         is_valid = false;
<span class="lineNum">     283 </span>            :       }
<span class="lineNum">     284 </span>            :       prev_repeatable = true;
<span class="lineNum">     285 </span>            :     } else {  // Not an escape sequence.
<span class="lineNum">     286 </span>            :       const char ch = regex[i];
<span class="lineNum">     287 </span>            : 
<span class="lineNum">     288 </span>            :       if (ch == '^' &amp;&amp; i &gt; 0) {
<span class="lineNum">     289 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i)
<span class="lineNum">     290 </span>            :                       &lt;&lt; &quot;'^' can only appear at the beginning.&quot;;
<span class="lineNum">     291 </span>            :         is_valid = false;
<span class="lineNum">     292 </span>            :       } else if (ch == '$' &amp;&amp; regex[i + 1] != '\0') {
<span class="lineNum">     293 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i)
<span class="lineNum">     294 </span>            :                       &lt;&lt; &quot;'$' can only appear at the end.&quot;;
<span class="lineNum">     295 </span>            :         is_valid = false;
<span class="lineNum">     296 </span>            :       } else if (IsInSet(ch, &quot;()[]{}|&quot;)) {
<span class="lineNum">     297 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i)
<span class="lineNum">     298 </span>            :                       &lt;&lt; &quot;'&quot; &lt;&lt; ch &lt;&lt; &quot;' is unsupported.&quot;;
<span class="lineNum">     299 </span>            :         is_valid = false;
<span class="lineNum">     300 </span>            :       } else if (IsRepeat(ch) &amp;&amp; !prev_repeatable) {
<span class="lineNum">     301 </span>            :         ADD_FAILURE() &lt;&lt; FormatRegexSyntaxError(regex, i)
<span class="lineNum">     302 </span>            :                       &lt;&lt; &quot;'&quot; &lt;&lt; ch &lt;&lt; &quot;' can only follow a repeatable token.&quot;;
<span class="lineNum">     303 </span>            :         is_valid = false;
<span class="lineNum">     304 </span>            :       }
<span class="lineNum">     305 </span>            : 
<span class="lineNum">     306 </span>            :       prev_repeatable = !IsInSet(ch, &quot;^$?*+&quot;);
<span class="lineNum">     307 </span>            :     }
<span class="lineNum">     308 </span>            :   }
<span class="lineNum">     309 </span>            : 
<span class="lineNum">     310 </span>            :   return is_valid;
<span class="lineNum">     311 </span>            : }
<span class="lineNum">     312 </span>            : 
<span class="lineNum">     313 </span>            : // Matches a repeated regex atom followed by a valid simple regular
<span class="lineNum">     314 </span>            : // expression.  The regex atom is defined as c if escaped is false,
<span class="lineNum">     315 </span>            : // or \c otherwise.  repeat is the repetition meta character (?, *,
<span class="lineNum">     316 </span>            : // or +).  The behavior is undefined if str contains too many
<span class="lineNum">     317 </span>            : // characters to be indexable by size_t, in which case the test will
<span class="lineNum">     318 </span>            : // probably time out anyway.  We are fine with this limitation as
<span class="lineNum">     319 </span>            : // std::string has it too.
<span class="lineNum">     320 </span>            : bool MatchRepetitionAndRegexAtHead(
<span class="lineNum">     321 </span>            :     bool escaped, char c, char repeat, const char* regex,
<span class="lineNum">     322 </span>            :     const char* str) {
<span class="lineNum">     323 </span>            :   const size_t min_count = (repeat == '+') ? 1 : 0;
<span class="lineNum">     324 </span>            :   const size_t max_count = (repeat == '?') ? 1 :
<span class="lineNum">     325 </span>            :       static_cast&lt;size_t&gt;(-1) - 1;
<span class="lineNum">     326 </span>            :   // We cannot call numeric_limits::max() as it conflicts with the
<span class="lineNum">     327 </span>            :   // max() macro on Windows.
<span class="lineNum">     328 </span>            : 
<span class="lineNum">     329 </span>            :   for (size_t i = 0; i &lt;= max_count; ++i) {
<span class="lineNum">     330 </span>            :     // We know that the atom matches each of the first i characters in str.
<span class="lineNum">     331 </span>            :     if (i &gt;= min_count &amp;&amp; MatchRegexAtHead(regex, str + i)) {
<span class="lineNum">     332 </span>            :       // We have enough matches at the head, and the tail matches too.
<span class="lineNum">     333 </span>            :       // Since we only care about *whether* the pattern matches str
<span class="lineNum">     334 </span>            :       // (as opposed to *how* it matches), there is no need to find a
<span class="lineNum">     335 </span>            :       // greedy match.
<span class="lineNum">     336 </span>            :       return true;
<span class="lineNum">     337 </span>            :     }
<span class="lineNum">     338 </span>            :     if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i]))
<span class="lineNum">     339 </span>            :       return false;
<span class="lineNum">     340 </span>            :   }
<span class="lineNum">     341 </span>            :   return false;
<span class="lineNum">     342 </span>            : }
<span class="lineNum">     343 </span>            : 
<span class="lineNum">     344 </span>            : // Returns true iff regex matches a prefix of str.  regex must be a
<span class="lineNum">     345 </span>            : // valid simple regular expression and not start with &quot;^&quot;, or the
<span class="lineNum">     346 </span>            : // result is undefined.
<span class="lineNum">     347 </span>            : bool MatchRegexAtHead(const char* regex, const char* str) {
<span class="lineNum">     348 </span>            :   if (*regex == '\0')  // An empty regex matches a prefix of anything.
<span class="lineNum">     349 </span>            :     return true;
<span class="lineNum">     350 </span>            : 
<span class="lineNum">     351 </span>            :   // &quot;$&quot; only matches the end of a string.  Note that regex being
<span class="lineNum">     352 </span>            :   // valid guarantees that there's nothing after &quot;$&quot; in it.
<span class="lineNum">     353 </span>            :   if (*regex == '$')
<span class="lineNum">     354 </span>            :     return *str == '\0';
<span class="lineNum">     355 </span>            : 
<span class="lineNum">     356 </span>            :   // Is the first thing in regex an escape sequence?
<span class="lineNum">     357 </span>            :   const bool escaped = *regex == '\\';
<span class="lineNum">     358 </span>            :   if (escaped)
<span class="lineNum">     359 </span>            :     ++regex;
<span class="lineNum">     360 </span>            :   if (IsRepeat(regex[1])) {
<span class="lineNum">     361 </span>            :     // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so
<span class="lineNum">     362 </span>            :     // here's an indirect recursion.  It terminates as the regex gets
<span class="lineNum">     363 </span>            :     // shorter in each recursion.
<span class="lineNum">     364 </span>            :     return MatchRepetitionAndRegexAtHead(
<span class="lineNum">     365 </span>            :         escaped, regex[0], regex[1], regex + 2, str);
<span class="lineNum">     366 </span>            :   } else {
<span class="lineNum">     367 </span>            :     // regex isn't empty, isn't &quot;$&quot;, and doesn't start with a
<span class="lineNum">     368 </span>            :     // repetition.  We match the first atom of regex with the first
<span class="lineNum">     369 </span>            :     // character of str and recurse.
<span class="lineNum">     370 </span>            :     return (*str != '\0') &amp;&amp; AtomMatchesChar(escaped, *regex, *str) &amp;&amp;
<span class="lineNum">     371 </span>            :         MatchRegexAtHead(regex + 1, str + 1);
<span class="lineNum">     372 </span>            :   }
<span class="lineNum">     373 </span>            : }
<span class="lineNum">     374 </span>            : 
<span class="lineNum">     375 </span>            : // Returns true iff regex matches any substring of str.  regex must be
<span class="lineNum">     376 </span>            : // a valid simple regular expression, or the result is undefined.
<span class="lineNum">     377 </span>            : //
<span class="lineNum">     378 </span>            : // The algorithm is recursive, but the recursion depth doesn't exceed
<span class="lineNum">     379 </span>            : // the regex length, so we won't need to worry about running out of
<span class="lineNum">     380 </span>            : // stack space normally.  In rare cases the time complexity can be
<span class="lineNum">     381 </span>            : // exponential with respect to the regex length + the string length,
<span class="lineNum">     382 </span>            : // but usually it's must faster (often close to linear).
<span class="lineNum">     383 </span>            : bool MatchRegexAnywhere(const char* regex, const char* str) {
<span class="lineNum">     384 </span>            :   if (regex == NULL || str == NULL)
<span class="lineNum">     385 </span>            :     return false;
<span class="lineNum">     386 </span>            : 
<span class="lineNum">     387 </span>            :   if (*regex == '^')
<span class="lineNum">     388 </span>            :     return MatchRegexAtHead(regex + 1, str);
<span class="lineNum">     389 </span>            : 
<span class="lineNum">     390 </span>            :   // A successful match can be anywhere in str.
<span class="lineNum">     391 </span>            :   do {
<span class="lineNum">     392 </span>            :     if (MatchRegexAtHead(regex, str))
<span class="lineNum">     393 </span>            :       return true;
<span class="lineNum">     394 </span>            :   } while (*str++ != '\0');
<span class="lineNum">     395 </span>            :   return false;
<span class="lineNum">     396 </span>            : }
<span class="lineNum">     397 </span>            : 
<span class="lineNum">     398 </span>            : // Implements the RE class.
<span class="lineNum">     399 </span>            : 
<span class="lineNum">     400 </span>            : RE::~RE() {
<span class="lineNum">     401 </span>            :   free(const_cast&lt;char*&gt;(pattern_));
<span class="lineNum">     402 </span>            :   free(const_cast&lt;char*&gt;(full_pattern_));
<span class="lineNum">     403 </span>            : }
<span class="lineNum">     404 </span>            : 
<span class="lineNum">     405 </span>            : // Returns true iff regular expression re matches the entire str.
<span class="lineNum">     406 </span>            : bool RE::FullMatch(const char* str, const RE&amp; re) {
<span class="lineNum">     407 </span>            :   return re.is_valid_ &amp;&amp; MatchRegexAnywhere(re.full_pattern_, str);
<span class="lineNum">     408 </span>            : }
<span class="lineNum">     409 </span>            : 
<span class="lineNum">     410 </span>            : // Returns true iff regular expression re matches a substring of str
<span class="lineNum">     411 </span>            : // (including str itself).
<span class="lineNum">     412 </span>            : bool RE::PartialMatch(const char* str, const RE&amp; re) {
<span class="lineNum">     413 </span>            :   return re.is_valid_ &amp;&amp; MatchRegexAnywhere(re.pattern_, str);
<span class="lineNum">     414 </span>            : }
<span class="lineNum">     415 </span>            : 
<span class="lineNum">     416 </span>            : // Initializes an RE from its string representation.
<span class="lineNum">     417 </span>            : void RE::Init(const char* regex) {
<span class="lineNum">     418 </span>            :   pattern_ = full_pattern_ = NULL;
<span class="lineNum">     419 </span>            :   if (regex != NULL) {
<span class="lineNum">     420 </span>            :     pattern_ = posix::StrDup(regex);
<span class="lineNum">     421 </span>            :   }
<span class="lineNum">     422 </span>            : 
<span class="lineNum">     423 </span>            :   is_valid_ = ValidateRegex(regex);
<span class="lineNum">     424 </span>            :   if (!is_valid_) {
<span class="lineNum">     425 </span>            :     // No need to calculate the full pattern when the regex is invalid.
<span class="lineNum">     426 </span>            :     return;
<span class="lineNum">     427 </span>            :   }
<span class="lineNum">     428 </span>            : 
<span class="lineNum">     429 </span>            :   const size_t len = strlen(regex);
<span class="lineNum">     430 </span>            :   // Reserves enough bytes to hold the regular expression used for a
<span class="lineNum">     431 </span>            :   // full match: we need space to prepend a '^', append a '$', and
<span class="lineNum">     432 </span>            :   // terminate the string with '\0'.
<span class="lineNum">     433 </span>            :   char* buffer = static_cast&lt;char*&gt;(malloc(len + 3));
<span class="lineNum">     434 </span>            :   full_pattern_ = buffer;
<span class="lineNum">     435 </span>            : 
<span class="lineNum">     436 </span>            :   if (*regex != '^')
<span class="lineNum">     437 </span>            :     *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.
<span class="lineNum">     438 </span>            : 
<span class="lineNum">     439 </span>            :   // We don't use snprintf or strncpy, as they trigger a warning when
<span class="lineNum">     440 </span>            :   // compiled with VC++ 8.0.
<span class="lineNum">     441 </span>            :   memcpy(buffer, regex, len);
<span class="lineNum">     442 </span>            :   buffer += len;
<span class="lineNum">     443 </span>            : 
<span class="lineNum">     444 </span>            :   if (len == 0 || regex[len - 1] != '$')
<span class="lineNum">     445 </span>            :     *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            :   *buffer = '\0';
<span class="lineNum">     448 </span>            : }
<span class="lineNum">     449 </span>            : 
<span class="lineNum">     450 </span>            : #endif  // GTEST_USES_POSIX_RE
<span class="lineNum">     451 </span>            : 
<span class="lineNum">     452 </span>            : const char kUnknownFile[] = &quot;unknown file&quot;;
<span class="lineNum">     453 </span>            : 
<a name="454"><span class="lineNum">     454 </span>            : // Formats a source file path and a line number as they would appear</a>
<span class="lineNum">     455 </span>            : // in an error message from the compiler used to compile this code.
<span class="lineNum">     456 </span><span class="lineNoCov">          0 : GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {</span>
<span class="lineNum">     457 </span><span class="lineNoCov">          0 :   const std::string file_name(file == NULL ? kUnknownFile : file);</span>
<span class="lineNum">     458 </span>            : 
<span class="lineNum">     459 </span><span class="lineNoCov">          0 :   if (line &lt; 0) {</span>
<span class="lineNum">     460 </span><span class="lineNoCov">          0 :     return file_name + &quot;:&quot;;</span>
<span class="lineNum">     461 </span>            :   }
<span class="lineNum">     462 </span>            : #ifdef _MSC_VER
<span class="lineNum">     463 </span>            :   return file_name + &quot;(&quot; + StreamableToString(line) + &quot;):&quot;;
<span class="lineNum">     464 </span>            : #else
<span class="lineNum">     465 </span><span class="lineNoCov">          0 :   return file_name + &quot;:&quot; + StreamableToString(line) + &quot;:&quot;;</span>
<span class="lineNum">     466 </span>            : #endif  // _MSC_VER
<span class="lineNum">     467 </span>            : }
<span class="lineNum">     468 </span>            : 
<span class="lineNum">     469 </span>            : // Formats a file location for compiler-independent XML output.
<span class="lineNum">     470 </span>            : // Although this function is not platform dependent, we put it next to
<span class="lineNum">     471 </span>            : // FormatFileLocation in order to contrast the two functions.
<a name="472"><span class="lineNum">     472 </span>            : // Note that FormatCompilerIndependentFileLocation() does NOT append colon</a>
<span class="lineNum">     473 </span>            : // to the file location it produces, unlike FormatFileLocation().
<span class="lineNum">     474 </span><span class="lineNoCov">          0 : GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(</span>
<span class="lineNum">     475 </span>            :     const char* file, int line) {
<span class="lineNum">     476 </span><span class="lineNoCov">          0 :   const std::string file_name(file == NULL ? kUnknownFile : file);</span>
<span class="lineNum">     477 </span>            : 
<span class="lineNum">     478 </span><span class="lineNoCov">          0 :   if (line &lt; 0)</span>
<span class="lineNum">     479 </span><span class="lineNoCov">          0 :     return file_name;</span>
<span class="lineNum">     480 </span>            :   else
<span class="lineNum">     481 </span><span class="lineNoCov">          0 :     return file_name + &quot;:&quot; + StreamableToString(line);</span>
<span class="lineNum">     482 </span>            : }
<a name="483"><span class="lineNum">     483 </span>            : </a>
<span class="lineNum">     484 </span>            : 
<span class="lineNum">     485 </span><span class="lineNoCov">          0 : GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)</span>
<span class="lineNum">     486 </span><span class="lineNoCov">          0 :     : severity_(severity) {</span>
<span class="lineNum">     487 </span>            :   const char* const marker =
<span class="lineNum">     488 </span>            :       severity == GTEST_INFO ?    &quot;[  INFO ]&quot; :
<span class="lineNum">     489 </span>            :       severity == GTEST_WARNING ? &quot;[WARNING]&quot; :
<span class="lineNum">     490 </span><span class="lineNoCov">          0 :       severity == GTEST_ERROR ?   &quot;[ ERROR ]&quot; : &quot;[ FATAL ]&quot;;</span>
<span class="lineNum">     491 </span><span class="lineNoCov">          0 :   GetStream() &lt;&lt; ::std::endl &lt;&lt; marker &lt;&lt; &quot; &quot;</span>
<span class="lineNum">     492 </span><span class="lineNoCov">          0 :               &lt;&lt; FormatFileLocation(file, line).c_str() &lt;&lt; &quot;: &quot;;</span>
<span class="lineNum">     493 </span><span class="lineNoCov">          0 : }</span>
<a name="494"><span class="lineNum">     494 </span>            : </a>
<span class="lineNum">     495 </span>            : // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
<span class="lineNum">     496 </span><span class="lineNoCov">          0 : GTestLog::~GTestLog() {</span>
<span class="lineNum">     497 </span><span class="lineNoCov">          0 :   GetStream() &lt;&lt; ::std::endl;</span>
<span class="lineNum">     498 </span><span class="lineNoCov">          0 :   if (severity_ == GTEST_FATAL) {</span>
<span class="lineNum">     499 </span><span class="lineNoCov">          0 :     fflush(stderr);</span>
<span class="lineNum">     500 </span><span class="lineNoCov">          0 :     posix::Abort();</span>
<span class="lineNum">     501 </span>            :   }
<span class="lineNum">     502 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     503 </span>            : // Disable Microsoft deprecation warnings for POSIX functions called from
<span class="lineNum">     504 </span>            : // this class (creat, dup, dup2, and close)
<span class="lineNum">     505 </span>            : #ifdef _MSC_VER
<span class="lineNum">     506 </span>            : # pragma warning(push)
<span class="lineNum">     507 </span>            : # pragma warning(disable: 4996)
<span class="lineNum">     508 </span>            : #endif  // _MSC_VER
<span class="lineNum">     509 </span>            : 
<span class="lineNum">     510 </span>            : #if GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">     511 </span>            : 
<span class="lineNum">     512 </span>            : // Object that captures an output stream (stdout/stderr).
<span class="lineNum">     513 </span>            : class CapturedStream {
<a name="514"><span class="lineNum">     514 </span>            :  public:</a>
<span class="lineNum">     515 </span>            :   // The ctor redirects the stream to a temporary file.
<span class="lineNum">     516 </span><span class="lineNoCov">          0 :   explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {</span>
<span class="lineNum">     517 </span>            : # if GTEST_OS_WINDOWS
<span class="lineNum">     518 </span>            :     char temp_dir_path[MAX_PATH + 1] = { '\0' };  // NOLINT
<span class="lineNum">     519 </span>            :     char temp_file_path[MAX_PATH + 1] = { '\0' };  // NOLINT
<span class="lineNum">     520 </span>            : 
<span class="lineNum">     521 </span>            :     ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);
<span class="lineNum">     522 </span>            :     const UINT success = ::GetTempFileNameA(temp_dir_path,
<span class="lineNum">     523 </span>            :                                             &quot;gtest_redir&quot;,
<span class="lineNum">     524 </span>            :                                             0,  // Generate unique file name.
<span class="lineNum">     525 </span>            :                                             temp_file_path);
<span class="lineNum">     526 </span>            :     GTEST_CHECK_(success != 0)
<span class="lineNum">     527 </span>            :         &lt;&lt; &quot;Unable to create a temporary file in &quot; &lt;&lt; temp_dir_path;
<span class="lineNum">     528 </span>            :     const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
<span class="lineNum">     529 </span>            :     GTEST_CHECK_(captured_fd != -1) &lt;&lt; &quot;Unable to open temporary file &quot;
<span class="lineNum">     530 </span>            :                                     &lt;&lt; temp_file_path;
<span class="lineNum">     531 </span>            :     filename_ = temp_file_path;
<span class="lineNum">     532 </span>            : # else
<span class="lineNum">     533 </span>            :     // There's no guarantee that a test has write access to the current
<span class="lineNum">     534 </span>            :     // directory, so we create the temporary file in the /tmp directory
<span class="lineNum">     535 </span>            :     // instead. We use /tmp on most systems, and /sdcard on Android.
<span class="lineNum">     536 </span>            :     // That's because Android doesn't have /tmp.
<span class="lineNum">     537 </span>            : #  if GTEST_OS_LINUX_ANDROID
<span class="lineNum">     538 </span>            :     // Note: Android applications are expected to call the framework's
<span class="lineNum">     539 </span>            :     // Context.getExternalStorageDirectory() method through JNI to get
<span class="lineNum">     540 </span>            :     // the location of the world-writable SD Card directory. However,
<span class="lineNum">     541 </span>            :     // this requires a Context handle, which cannot be retrieved
<span class="lineNum">     542 </span>            :     // globally from native code. Doing so also precludes running the
<span class="lineNum">     543 </span>            :     // code as part of a regular standalone executable, which doesn't
<span class="lineNum">     544 </span>            :     // run in a Dalvik process (e.g. when running it through 'adb shell').
<span class="lineNum">     545 </span>            :     //
<span class="lineNum">     546 </span>            :     // The location /sdcard is directly accessible from native code
<span class="lineNum">     547 </span>            :     // and is the only location (unofficially) supported by the Android
<span class="lineNum">     548 </span>            :     // team. It's generally a symlink to the real SD Card mount point
<span class="lineNum">     549 </span>            :     // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or
<span class="lineNum">     550 </span>            :     // other OEM-customized locations. Never rely on these, and always
<span class="lineNum">     551 </span>            :     // use /sdcard.
<span class="lineNum">     552 </span>            :     char name_template[] = &quot;/sdcard/gtest_captured_stream.XXXXXX&quot;;
<span class="lineNum">     553 </span>            : #  else
<span class="lineNum">     554 </span><span class="lineNoCov">          0 :     char name_template[] = &quot;/tmp/captured_stream.XXXXXX&quot;;</span>
<span class="lineNum">     555 </span>            : #  endif  // GTEST_OS_LINUX_ANDROID
<span class="lineNum">     556 </span><span class="lineNoCov">          0 :     const int captured_fd = mkstemp(name_template);</span>
<span class="lineNum">     557 </span><span class="lineNoCov">          0 :     filename_ = name_template;</span>
<span class="lineNum">     558 </span>            : # endif  // GTEST_OS_WINDOWS
<span class="lineNum">     559 </span><span class="lineNoCov">          0 :     fflush(NULL);</span>
<span class="lineNum">     560 </span><span class="lineNoCov">          0 :     dup2(captured_fd, fd_);</span>
<span class="lineNum">     561 </span><span class="lineNoCov">          0 :     close(captured_fd);</span>
<a name="562"><span class="lineNum">     562 </span><span class="lineNoCov">          0 :   }</span></a>
<span class="lineNum">     563 </span>            : 
<span class="lineNum">     564 </span><span class="lineNoCov">          0 :   ~CapturedStream() {</span>
<span class="lineNum">     565 </span><span class="lineNoCov">          0 :     remove(filename_.c_str());</span>
<a name="566"><span class="lineNum">     566 </span><span class="lineNoCov">          0 :   }</span></a>
<span class="lineNum">     567 </span>            : 
<span class="lineNum">     568 </span><span class="lineNoCov">          0 :   std::string GetCapturedString() {</span>
<span class="lineNum">     569 </span><span class="lineNoCov">          0 :     if (uncaptured_fd_ != -1) {</span>
<span class="lineNum">     570 </span>            :       // Restores the original stream.
<span class="lineNum">     571 </span><span class="lineNoCov">          0 :       fflush(NULL);</span>
<span class="lineNum">     572 </span><span class="lineNoCov">          0 :       dup2(uncaptured_fd_, fd_);</span>
<span class="lineNum">     573 </span><span class="lineNoCov">          0 :       close(uncaptured_fd_);</span>
<span class="lineNum">     574 </span><span class="lineNoCov">          0 :       uncaptured_fd_ = -1;</span>
<span class="lineNum">     575 </span>            :     }
<span class="lineNum">     576 </span>            : 
<span class="lineNum">     577 </span><span class="lineNoCov">          0 :     FILE* const file = posix::FOpen(filename_.c_str(), &quot;r&quot;);</span>
<span class="lineNum">     578 </span><span class="lineNoCov">          0 :     const std::string content = ReadEntireFile(file);</span>
<span class="lineNum">     579 </span><span class="lineNoCov">          0 :     posix::FClose(file);</span>
<span class="lineNum">     580 </span><span class="lineNoCov">          0 :     return content;</span>
<span class="lineNum">     581 </span>            :   }
<span class="lineNum">     582 </span>            : 
<span class="lineNum">     583 </span>            :  private:
<span class="lineNum">     584 </span>            :   // Reads the entire content of a file as an std::string.
<span class="lineNum">     585 </span>            :   static std::string ReadEntireFile(FILE* file);
<span class="lineNum">     586 </span>            : 
<span class="lineNum">     587 </span>            :   // Returns the size (in bytes) of a file.
<span class="lineNum">     588 </span>            :   static size_t GetFileSize(FILE* file);
<span class="lineNum">     589 </span>            : 
<span class="lineNum">     590 </span>            :   const int fd_;  // A stream to capture.
<span class="lineNum">     591 </span>            :   int uncaptured_fd_;
<span class="lineNum">     592 </span>            :   // Name of the temporary file holding the stderr output.
<span class="lineNum">     593 </span>            :   ::std::string filename_;
<span class="lineNum">     594 </span>            : 
<span class="lineNum">     595 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
<span class="lineNum">     596 </span>            : };
<a name="597"><span class="lineNum">     597 </span>            : </a>
<span class="lineNum">     598 </span>            : // Returns the size (in bytes) of a file.
<span class="lineNum">     599 </span><span class="lineNoCov">          0 : size_t CapturedStream::GetFileSize(FILE* file) {</span>
<span class="lineNum">     600 </span><span class="lineNoCov">          0 :   fseek(file, 0, SEEK_END);</span>
<span class="lineNum">     601 </span><span class="lineNoCov">          0 :   return static_cast&lt;size_t&gt;(ftell(file));</span>
<span class="lineNum">     602 </span>            : }
<a name="603"><span class="lineNum">     603 </span>            : </a>
<span class="lineNum">     604 </span>            : // Reads the entire content of a file as a string.
<span class="lineNum">     605 </span><span class="lineNoCov">          0 : std::string CapturedStream::ReadEntireFile(FILE* file) {</span>
<span class="lineNum">     606 </span><span class="lineNoCov">          0 :   const size_t file_size = GetFileSize(file);</span>
<span class="lineNum">     607 </span><span class="lineNoCov">          0 :   char* const buffer = new char[file_size];</span>
<span class="lineNum">     608 </span>            : 
<span class="lineNum">     609 </span><span class="lineNoCov">          0 :   size_t bytes_last_read = 0;  // # of bytes read in the last fread()</span>
<span class="lineNum">     610 </span><span class="lineNoCov">          0 :   size_t bytes_read = 0;       // # of bytes read so far</span>
<span class="lineNum">     611 </span>            : 
<span class="lineNum">     612 </span><span class="lineNoCov">          0 :   fseek(file, 0, SEEK_SET);</span>
<span class="lineNum">     613 </span>            : 
<span class="lineNum">     614 </span>            :   // Keeps reading the file until we cannot read further or the
<span class="lineNum">     615 </span>            :   // pre-determined file size is reached.
<span class="lineNum">     616 </span><span class="lineNoCov">          0 :   do {</span>
<span class="lineNum">     617 </span><span class="lineNoCov">          0 :     bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);</span>
<span class="lineNum">     618 </span><span class="lineNoCov">          0 :     bytes_read += bytes_last_read;</span>
<span class="lineNum">     619 </span><span class="lineNoCov">          0 :   } while (bytes_last_read &gt; 0 &amp;&amp; bytes_read &lt; file_size);</span>
<span class="lineNum">     620 </span>            : 
<span class="lineNum">     621 </span><span class="lineNoCov">          0 :   const std::string content(buffer, bytes_read);</span>
<span class="lineNum">     622 </span><span class="lineNoCov">          0 :   delete[] buffer;</span>
<span class="lineNum">     623 </span>            : 
<span class="lineNum">     624 </span><span class="lineNoCov">          0 :   return content;</span>
<span class="lineNum">     625 </span>            : }
<span class="lineNum">     626 </span>            : 
<span class="lineNum">     627 </span>            : # ifdef _MSC_VER
<span class="lineNum">     628 </span>            : #  pragma warning(pop)
<span class="lineNum">     629 </span>            : # endif  // _MSC_VER
<span class="lineNum">     630 </span>            : 
<span class="lineNum">     631 </span>            : static CapturedStream* g_captured_stderr = NULL;
<span class="lineNum">     632 </span>            : static CapturedStream* g_captured_stdout = NULL;
<a name="633"><span class="lineNum">     633 </span>            : </a>
<span class="lineNum">     634 </span>            : // Starts capturing an output stream (stdout/stderr).
<span class="lineNum">     635 </span><span class="lineNoCov">          0 : void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {</span>
<span class="lineNum">     636 </span><span class="lineNoCov">          0 :   if (*stream != NULL) {</span>
<span class="lineNum">     637 </span><span class="lineNoCov">          0 :     GTEST_LOG_(FATAL) &lt;&lt; &quot;Only one &quot; &lt;&lt; stream_name</span>
<span class="lineNum">     638 </span><span class="lineNoCov">          0 :                       &lt;&lt; &quot; capturer can exist at a time.&quot;;</span>
<span class="lineNum">     639 </span>            :   }
<span class="lineNum">     640 </span><span class="lineNoCov">          0 :   *stream = new CapturedStream(fd);</span>
<span class="lineNum">     641 </span><span class="lineNoCov">          0 : }</span>
<a name="642"><span class="lineNum">     642 </span>            : </a>
<span class="lineNum">     643 </span>            : // Stops capturing the output stream and returns the captured string.
<span class="lineNum">     644 </span><span class="lineNoCov">          0 : std::string GetCapturedStream(CapturedStream** captured_stream) {</span>
<span class="lineNum">     645 </span><span class="lineNoCov">          0 :   const std::string content = (*captured_stream)-&gt;GetCapturedString();</span>
<span class="lineNum">     646 </span>            : 
<span class="lineNum">     647 </span><span class="lineNoCov">          0 :   delete *captured_stream;</span>
<span class="lineNum">     648 </span><span class="lineNoCov">          0 :   *captured_stream = NULL;</span>
<span class="lineNum">     649 </span>            : 
<span class="lineNum">     650 </span><span class="lineNoCov">          0 :   return content;</span>
<span class="lineNum">     651 </span>            : }
<a name="652"><span class="lineNum">     652 </span>            : </a>
<span class="lineNum">     653 </span>            : // Starts capturing stdout.
<span class="lineNum">     654 </span><span class="lineNoCov">          0 : void CaptureStdout() {</span>
<span class="lineNum">     655 </span><span class="lineNoCov">          0 :   CaptureStream(kStdOutFileno, &quot;stdout&quot;, &amp;g_captured_stdout);</span>
<span class="lineNum">     656 </span><span class="lineNoCov">          0 : }</span>
<a name="657"><span class="lineNum">     657 </span>            : </a>
<span class="lineNum">     658 </span>            : // Starts capturing stderr.
<span class="lineNum">     659 </span><span class="lineNoCov">          0 : void CaptureStderr() {</span>
<span class="lineNum">     660 </span><span class="lineNoCov">          0 :   CaptureStream(kStdErrFileno, &quot;stderr&quot;, &amp;g_captured_stderr);</span>
<span class="lineNum">     661 </span><span class="lineNoCov">          0 : }</span>
<a name="662"><span class="lineNum">     662 </span>            : </a>
<span class="lineNum">     663 </span>            : // Stops capturing stdout and returns the captured string.
<span class="lineNum">     664 </span><span class="lineNoCov">          0 : std::string GetCapturedStdout() {</span>
<span class="lineNum">     665 </span><span class="lineNoCov">          0 :   return GetCapturedStream(&amp;g_captured_stdout);</span>
<span class="lineNum">     666 </span>            : }
<a name="667"><span class="lineNum">     667 </span>            : </a>
<span class="lineNum">     668 </span>            : // Stops capturing stderr and returns the captured string.
<span class="lineNum">     669 </span><span class="lineNoCov">          0 : std::string GetCapturedStderr() {</span>
<span class="lineNum">     670 </span><span class="lineNoCov">          0 :   return GetCapturedStream(&amp;g_captured_stderr);</span>
<span class="lineNum">     671 </span>            : }
<span class="lineNum">     672 </span>            : 
<span class="lineNum">     673 </span>            : #endif  // GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">     674 </span>            : 
<span class="lineNum">     675 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">     676 </span>            : 
<span class="lineNum">     677 </span>            : // A copy of all command line arguments.  Set by InitGoogleTest().
<span class="lineNum">     678 </span><span class="lineNoCov">          0 : ::std::vector&lt;testing::internal::string&gt; g_argvs;</span>
<span class="lineNum">     679 </span>            : 
<span class="lineNum">     680 </span>            : static const ::std::vector&lt;testing::internal::string&gt;* g_injected_test_argvs =
<a name="681"><span class="lineNum">     681 </span>            :                                         NULL;  // Owned.</a>
<span class="lineNum">     682 </span>            : 
<span class="lineNum">     683 </span><span class="lineNoCov">          0 : void SetInjectableArgvs(const ::std::vector&lt;testing::internal::string&gt;* argvs) {</span>
<span class="lineNum">     684 </span><span class="lineNoCov">          0 :   if (g_injected_test_argvs != argvs)</span>
<span class="lineNum">     685 </span><span class="lineNoCov">          0 :     delete g_injected_test_argvs;</span>
<span class="lineNum">     686 </span><span class="lineNoCov">          0 :   g_injected_test_argvs = argvs;</span>
<a name="687"><span class="lineNum">     687 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     688 </span>            : 
<span class="lineNum">     689 </span><span class="lineNoCov">          0 : const ::std::vector&lt;testing::internal::string&gt;&amp; GetInjectableArgvs() {</span>
<span class="lineNum">     690 </span><span class="lineNoCov">          0 :   if (g_injected_test_argvs != NULL) {</span>
<span class="lineNum">     691 </span><span class="lineNoCov">          0 :     return *g_injected_test_argvs;</span>
<span class="lineNum">     692 </span>            :   }
<span class="lineNum">     693 </span><span class="lineNoCov">          0 :   return g_argvs;</span>
<span class="lineNum">     694 </span>            : }
<span class="lineNum">     695 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">     696 </span>            : 
<span class="lineNum">     697 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     698 </span>            : namespace posix {
<span class="lineNum">     699 </span>            : void Abort() {
<span class="lineNum">     700 </span>            :   DebugBreak();
<span class="lineNum">     701 </span>            :   TerminateProcess(GetCurrentProcess(), 1);
<span class="lineNum">     702 </span>            : }
<span class="lineNum">     703 </span>            : }  // namespace posix
<span class="lineNum">     704 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     705 </span>            : 
<span class="lineNum">     706 </span>            : // Returns the name of the environment variable corresponding to the
<a name="707"><span class="lineNum">     707 </span>            : // given flag.  For example, FlagToEnvVar(&quot;foo&quot;) will return</a>
<span class="lineNum">     708 </span>            : // &quot;GTEST_FOO&quot; in the open-source version.
<span class="lineNum">     709 </span><span class="lineNoCov">          0 : static std::string FlagToEnvVar(const char* flag) {</span>
<span class="lineNum">     710 </span>            :   const std::string full_flag =
<span class="lineNum">     711 </span><span class="lineNoCov">          0 :       (Message() &lt;&lt; GTEST_FLAG_PREFIX_ &lt;&lt; flag).GetString();</span>
<span class="lineNum">     712 </span>            : 
<span class="lineNum">     713 </span><span class="lineNoCov">          0 :   Message env_var;</span>
<span class="lineNum">     714 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i != full_flag.length(); i++) {</span>
<span class="lineNum">     715 </span><span class="lineNoCov">          0 :     env_var &lt;&lt; ToUpper(full_flag.c_str()[i]);</span>
<span class="lineNum">     716 </span>            :   }
<span class="lineNum">     717 </span>            : 
<span class="lineNum">     718 </span><span class="lineNoCov">          0 :   return env_var.GetString();</span>
<span class="lineNum">     719 </span>            : }
<span class="lineNum">     720 </span>            : 
<span class="lineNum">     721 </span>            : // Parses 'str' for a 32-bit signed integer.  If successful, writes
<a name="722"><span class="lineNum">     722 </span>            : // the result to *value and returns true; otherwise leaves *value</a>
<span class="lineNum">     723 </span>            : // unchanged and returns false.
<span class="lineNum">     724 </span><span class="lineNoCov">          0 : bool ParseInt32(const Message&amp; src_text, const char* str, Int32* value) {</span>
<span class="lineNum">     725 </span>            :   // Parses the environment variable as a decimal integer.
<span class="lineNum">     726 </span><span class="lineNoCov">          0 :   char* end = NULL;</span>
<span class="lineNum">     727 </span><span class="lineNoCov">          0 :   const long long_value = strtol(str, &amp;end, 10);  // NOLINT</span>
<span class="lineNum">     728 </span>            : 
<span class="lineNum">     729 </span>            :   // Has strtol() consumed all characters in the string?
<span class="lineNum">     730 </span><span class="lineNoCov">          0 :   if (*end != '\0') {</span>
<span class="lineNum">     731 </span>            :     // No - an invalid character was encountered.
<span class="lineNum">     732 </span><span class="lineNoCov">          0 :     Message msg;</span>
<span class="lineNum">     733 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;WARNING: &quot; &lt;&lt; src_text</span>
<span class="lineNum">     734 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot; is expected to be a 32-bit integer, but actually&quot;</span>
<span class="lineNum">     735 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot; has value \&quot;&quot; &lt;&lt; str &lt;&lt; &quot;\&quot;.\n&quot;;</span>
<span class="lineNum">     736 </span><span class="lineNoCov">          0 :     printf(&quot;%s&quot;, msg.GetString().c_str());</span>
<span class="lineNum">     737 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">     738 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">     739 </span>            :   }
<span class="lineNum">     740 </span>            : 
<span class="lineNum">     741 </span>            :   // Is the parsed value in the range of an Int32?
<span class="lineNum">     742 </span><span class="lineNoCov">          0 :   const Int32 result = static_cast&lt;Int32&gt;(long_value);</span>
<span class="lineNum">     743 </span><span class="lineNoCov">          0 :   if (long_value == LONG_MAX || long_value == LONG_MIN ||</span>
<span class="lineNum">     744 </span>            :       // The parsed value overflows as a long.  (strtol() returns
<span class="lineNum">     745 </span>            :       // LONG_MAX or LONG_MIN when the input overflows.)
<span class="lineNum">     746 </span><span class="lineNoCov">          0 :       result != long_value</span>
<span class="lineNum">     747 </span>            :       // The parsed value overflows as an Int32.
<span class="lineNum">     748 </span>            :       ) {
<span class="lineNum">     749 </span><span class="lineNoCov">          0 :     Message msg;</span>
<span class="lineNum">     750 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;WARNING: &quot; &lt;&lt; src_text</span>
<span class="lineNum">     751 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot; is expected to be a 32-bit integer, but actually&quot;</span>
<span class="lineNum">     752 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot; has value &quot; &lt;&lt; str &lt;&lt; &quot;, which overflows.\n&quot;;</span>
<span class="lineNum">     753 </span><span class="lineNoCov">          0 :     printf(&quot;%s&quot;, msg.GetString().c_str());</span>
<span class="lineNum">     754 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">     755 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">     756 </span>            :   }
<span class="lineNum">     757 </span>            : 
<span class="lineNum">     758 </span><span class="lineNoCov">          0 :   *value = result;</span>
<span class="lineNum">     759 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">     760 </span>            : }
<span class="lineNum">     761 </span>            : 
<span class="lineNum">     762 </span>            : // Reads and returns the Boolean environment variable corresponding to
<span class="lineNum">     763 </span>            : // the given flag; if it's not set, returns default_value.
<a name="764"><span class="lineNum">     764 </span>            : //</a>
<span class="lineNum">     765 </span>            : // The value is considered true iff it's not &quot;0&quot;.
<span class="lineNum">     766 </span><span class="lineNoCov">          0 : bool BoolFromGTestEnv(const char* flag, bool default_value) {</span>
<span class="lineNum">     767 </span><span class="lineNoCov">          0 :   const std::string env_var = FlagToEnvVar(flag);</span>
<span class="lineNum">     768 </span><span class="lineNoCov">          0 :   const char* const string_value = posix::GetEnv(env_var.c_str());</span>
<span class="lineNum">     769 </span>            :   return string_value == NULL ?
<span class="lineNum">     770 </span><span class="lineNoCov">          0 :       default_value : strcmp(string_value, &quot;0&quot;) != 0;</span>
<span class="lineNum">     771 </span>            : }
<span class="lineNum">     772 </span>            : 
<span class="lineNum">     773 </span>            : // Reads and returns a 32-bit integer stored in the environment
<a name="774"><span class="lineNum">     774 </span>            : // variable corresponding to the given flag; if it isn't set or</a>
<span class="lineNum">     775 </span>            : // doesn't represent a valid 32-bit integer, returns default_value.
<span class="lineNum">     776 </span><span class="lineNoCov">          0 : Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {</span>
<span class="lineNum">     777 </span><span class="lineNoCov">          0 :   const std::string env_var = FlagToEnvVar(flag);</span>
<span class="lineNum">     778 </span><span class="lineNoCov">          0 :   const char* const string_value = posix::GetEnv(env_var.c_str());</span>
<span class="lineNum">     779 </span><span class="lineNoCov">          0 :   if (string_value == NULL) {</span>
<span class="lineNum">     780 </span>            :     // The environment variable is not set.
<span class="lineNum">     781 </span><span class="lineNoCov">          0 :     return default_value;</span>
<span class="lineNum">     782 </span>            :   }
<span class="lineNum">     783 </span>            : 
<span class="lineNum">     784 </span><span class="lineNoCov">          0 :   Int32 result = default_value;</span>
<span class="lineNum">     785 </span><span class="lineNoCov">          0 :   if (!ParseInt32(Message() &lt;&lt; &quot;Environment variable &quot; &lt;&lt; env_var,</span>
<span class="lineNum">     786 </span>            :                   string_value, &amp;result)) {
<span class="lineNum">     787 </span><span class="lineNoCov">          0 :     printf(&quot;The default value %s is used.\n&quot;,</span>
<span class="lineNum">     788 </span><span class="lineNoCov">          0 :            (Message() &lt;&lt; default_value).GetString().c_str());</span>
<span class="lineNum">     789 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">     790 </span><span class="lineNoCov">          0 :     return default_value;</span>
<span class="lineNum">     791 </span>            :   }
<span class="lineNum">     792 </span>            : 
<span class="lineNum">     793 </span><span class="lineNoCov">          0 :   return result;</span>
<span class="lineNum">     794 </span>            : }
<span class="lineNum">     795 </span>            : 
<a name="796"><span class="lineNum">     796 </span>            : // Reads and returns the string environment variable corresponding to</a>
<span class="lineNum">     797 </span>            : // the given flag; if it's not set, returns default_value.
<span class="lineNum">     798 </span><span class="lineNoCov">          0 : const char* StringFromGTestEnv(const char* flag, const char* default_value) {</span>
<span class="lineNum">     799 </span><span class="lineNoCov">          0 :   const std::string env_var = FlagToEnvVar(flag);</span>
<span class="lineNum">     800 </span><span class="lineNoCov">          0 :   const char* const value = posix::GetEnv(env_var.c_str());</span>
<span class="lineNum">     801 </span><span class="lineNoCov">          0 :   return value == NULL ? default_value : value;</span>
<span class="lineNum">     802 </span>            : }
<span class="lineNum">     803 </span>            : 
<span class="lineNum">     804 </span>            : }  // namespace internal
<span class="lineNum">     805 </span>            : }  // namespace testing
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
